/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Requests.MachineManagement.Components;

/**
 * This class represents the I/O settings of a virtual machine.
 *
 * @author Angel Sanadinov
 */
public class IOSettings extends MachineManagementComponent
{
    private boolean cacheStatus;    //cache state
    private int cacheSize;          //cache size in MB
    private int cacheMaxBandwidth;  //maximum cache bandwidth in MB/s; 0 for unlim

    /**
     * Constructs an I/O settings object with the specified data.
     *
     * @param cacheStatus the state of the I/O cache
     * @param cacheSize the size of the I/O cache in MB
     * @param cacheMaxBandwidth the maximum I/O cache bandwidth in MB/s (0 for unlimited)
     */
    public IOSettings(boolean cacheStatus, int cacheSize, int cacheMaxBandwidth)
    {
        this.cacheStatus = cacheStatus;
        this.cacheSize = cacheSize;
        this.cacheMaxBandwidth = cacheMaxBandwidth;
    }

    /**
     * Retrieves the state of the I/O cache.
     *
     * @return <code>true</code> if the cache is enabled of <code>false</code>
     *         if it is not
     */
    public boolean getCacheStatus()
    {
        return cacheStatus;
    }

    /**
     * Retrieves the size of the I/O cache.
     *
     * @return the I/O cache size in MB
     */
    public int getCacheSize()
    {
        return cacheSize;
    }

    /**
     * Retrieves the maximum I/O cache bandwidth.
     *
     * @return the cache bandwidth in MB/s
     */
    public int getCacheMaxBandwidth()
    {
        return cacheMaxBandwidth;
    }

    @Override
    public boolean isValid()
    {
        if(cacheSize >= 0 && cacheMaxBandwidth >= 0)
            return true;
        else
            return false;
    }
}
